
/*
 * Copyright (C) 2011 hljdrl@gmail.com
 * 
 *            mail:hljdrl@gmail.com
 * 
 * All rights reserved.
 */
package org.andtools.utils;

import java.util.Hashtable;

import android.app.NotificationManager;

public class NotificationValues {
	
	private static Hashtable<String, AbsNotification> ObjHasTable = new Hashtable<String, AbsNotification>();
	
	private static NotificationManager notManager;
	
	public static void show(String key){
		
		if(ObjHasTable.containsKey(key)){
			AbsNotification absNot = ObjHasTable.get(key);
			if(notManager!=null){
				notManager.notify(absNot.getId(), absNot.getNotification());
			}
		}
	}
	public static void Cancel(String key){
		
		if(ObjHasTable.containsKey(key)){
			AbsNotification absNot = ObjHasTable.get(key);
			if(notManager!=null){
				notManager.cancel(absNot.getId());
			}
		}
	}
	public static void add(AbsNotification absNot){
		synchronized(NotificationValues.class){
			if(ObjHasTable==null){
				ObjHasTable = new Hashtable<String, AbsNotification>();
			}
			String key =String.valueOf( absNot.getId());
			ObjHasTable.put(key, absNot);
		}
	}
	public static void romove(String key){
		synchronized(NotificationValues.class){
			if(ObjHasTable!=null){
				ObjHasTable.remove(key);
			}
		}
	}
	
	public static void release()
	{
		synchronized(NotificationValues.class){
			if(ObjHasTable!=null){
				ObjHasTable.clear();
				ObjHasTable = null;
			}
		}
	}

}
